﻿using Microsoft.EntityFrameworkCore.Migrations;

namespace EF_Cord.Migrations
{
    public partial class S10 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Mune",
                columns: table => new
                {
                    MId = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    MName = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    EId = table.Column<int>(type: "int", nullable: false),
                    MuneMId = table.Column<int>(type: "int", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Mune", x => x.MId);
                    table.ForeignKey(
                        name: "FK_Mune_Mune_MuneMId",
                        column: x => x.MuneMId,
                        principalTable: "Mune",
                        principalColumn: "MId",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "RoleMune",
                columns: table => new
                {
                    LId = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    RId = table.Column<int>(type: "int", nullable: false),
                    MId = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RoleMune", x => x.LId);
                    table.ForeignKey(
                        name: "FK_RoleMune_Mune_MId",
                        column: x => x.MId,
                        principalTable: "Mune",
                        principalColumn: "MId",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_RoleMune_Roles_RId",
                        column: x => x.RId,
                        principalTable: "Roles",
                        principalColumn: "RId",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_Mune_MuneMId",
                table: "Mune",
                column: "MuneMId");

            migrationBuilder.CreateIndex(
                name: "IX_RoleMune_MId",
                table: "RoleMune",
                column: "MId");

            migrationBuilder.CreateIndex(
                name: "IX_RoleMune_RId",
                table: "RoleMune",
                column: "RId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "RoleMune");

            migrationBuilder.DropTable(
                name: "Mune");
        }
    }
}
